package oop2;

/**
 * @author oldliu
 * @since 1.0
 */
public class Cat {

    String name;
    String type;
    public Cat(){

    }
    public Cat(String name, String type) {
        this.name = name;
        this.type = type;
    }

    public void show(){
//        String type="xxx";
//        System.out.println(type);
        System.out.println(this.name+","+this.type);
    }
    //方法的参数相当于局部变量
    public void bite(String name){
        System.out.println(this.name+"咬了"+name);
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof Cat){
            Cat c=(Cat)obj;
            //name一致，就是相同
            if(this.name==null && c.name==null)
                return true;
            return this.name!=null && this.name.equals(c.name);
        }
        //abc abc==true,String 重写了equals
        return false;
        //return super.equals(obj);
    }

    @Override
    public int hashCode() {
        return this.name==null?0:this.name.hashCode();
    }
}
